﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;
public partial class AdminManage_Edit_ZLEdit : System.Web.UI.Page
{
    public string zlid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        zlid = Request["zlid"];
        bind();
    }


    private void bind()
    {
        ZLInfo zlquery = new ZLInfo();
        int ZLID = Convert.ToInt32(zlid);
        DataSet ds = zlquery.GetAllInfoWithSet(ZLID);
        DataRowView dv = ds.Tables[0].DefaultView[0];


        FileTitle.Text = Convert.ToString(dv.Row["TITLE"]);
        GC_DEPART.Text = Convert.ToString(dv.Row["GC_DEPART"]);
        FILE_ID.Text = Convert.ToString(dv.Row["FILE_ID"]);
        TITLE_.Text = Convert.ToString(dv.Row["TITLE"]);
        UNIT.Text = Convert.ToString(dv.Row["UNIT"]);
        HX_PEOPLE.Text = Convert.ToString(dv.Row["HX_PEOPLE"]);
        PEOJ_NAME.Text = Convert.ToString(dv.Row["PEOJ_NAME"]);
        PEOJ_CODE.Text = Convert.ToString(dv.Row["PEOJ_CODE"]);



        DATA_CLASS.Text = Convert.ToString(dv.Row["DATA_CLASS"]);
        CLASS_CODE.Text = Convert.ToString(dv.Row["CLASS_CODE"]);
        XZArea.Text = Convert.ToString(dv.Row["ADMIN_REGION"]);//行政区划
        ADMINREG_CODE.Text = Convert.ToString(dv.Row["ADMINREG_CODE"]);
        MINE_NAME.Text = Convert.ToString(dv.Row["MINE_NAME"]);
        SHEET_NAME.Text = Convert.ToString(dv.Row["SHEET_NAME"]);
        SHEET_ID.Text = Convert.ToString(dv.Row["SHEET_ID"]);
        WORK_LEVEL.Text = Convert.ToString(dv.Row["WORK_LEVEL"]);

        WORKLEVEL_ID.Text = Convert.ToString(dv.Row["WORKLEVEL_ID"]);
        START_DATE.Text = Convert.ToString(dv.Row["START_DATE"]);
        //START_DATE_M.Text = Convert.ToString(dv.Row["START_DATE_M"]);
        //START_DATE_D.Text = Convert.ToString(dv.Row["START_DATE_D"]);
        END_DATE.Text = Convert.ToString(dv.Row["END_DATE"]);
        //END_DATE_M.Text = Convert.ToString(dv.Row["END_DATE_M"]);
        //END_DATE_D.Text = Convert.ToString(dv.Row["END_DATE_D"]);
        START_LONGITUDE_D.Text = Convert.ToString(dv.Row["START_LONGITUDE"]).Substring(0,3);

        START_LONGITUDE_F.Text = Convert.ToString(dv.Row["START_LONGITUDE"]).Substring(3,2);
        START_LONGITUDE_M.Text = Convert.ToString(dv.Row["START_LONGITUDE"]).Substring(5);
        END_LONGITUDE_D.Text = Convert.ToString(dv.Row["END_LONGITUDE"]).Substring(0,3); 
        END_LONGITUDE_F.Text = Convert.ToString(dv.Row["END_LONGITUDE"]).Substring(3,2); 
        END_LONGITUDE_M.Text = Convert.ToString(dv.Row["END_LONGITUDE"]).Substring(5); 
        START_LATITUDE_D.Text = Convert.ToString(dv.Row["START_LATITUDE"]).Substring(0,2); 
        START_LATITUDE_F.Text = Convert.ToString(dv.Row["START_LATITUDE"]).Substring(2,2);

        START_LATITUDE_M.Text = Convert.ToString(dv.Row["START_LATITUDE"]).Substring(4);

        END_LATITUDE_D.Text = Convert.ToString(dv.Row["END_LATITUDE"]).Substring(0,2);
        END_LATITUDE_F.Text = Convert.ToString(dv.Row["END_LATITUDE"]).Substring(2,2);
        END_LATITUDE_M.Text = Convert.ToString(dv.Row["END_LATITUDE"]).Substring(4);
        MineType.Text = Convert.ToString(dv.Row["MAJOR_MINE"]);//主要矿种
        MINE_CODE.Text = Convert.ToString(dv.Row["MINE_CODE"]);
        PUTIN_DATE.Text = Convert.ToString(dv.Row["PUTIN_DATE"]);
        //PUTIN_DATE_M.Text = Convert.ToString(dv.Row["PUTIN_DATE_M"]);
        //PUTIN_DATE_D.Text = Convert.ToString(dv.Row["PUTIN_DATE_D"]);

        TRANSF_CODE.Text = Convert.ToString(dv.Row["TRANSF_CODE"]);
        YXIN_NUM_ZL.Text = Convert.ToString(dv.Row["YXIN_NUM_ZL"]);
        YXIN_NUM_X.Text = Convert.ToString(dv.Row["YXIN_NUM_X"]);
        YXIN_NUM_M.Text = Convert.ToString(dv.Row["YXIN_NUM_M"]);
        YXIE_NUM_ZL.Text = Convert.ToString(dv.Row["YXIE_NUM_ZL"]);
        YXIE_NUM_X.Text = Convert.ToString(dv.Row["YXIE_NUM_X"]);
        YXIE_NUM_D.Text = Convert.ToString(dv.Row["YXIE_NUM_D"]);
        BB_NUM_X.Text = Convert.ToString(dv.Row["BB_NUM_X"]);


        BB_NUM_K_BIG.Text = Convert.ToString(dv.Row["BB_NUM_K_BIG"]);

        BB_NUM_K.Text = Convert.ToString(dv.Row["BB_NUM_K"]);
        YXIN_NUM_ZL.Text = Convert.ToString(dv.Row["YXIN_NUM_ZL"]);
        GP_NUM_H.Text = Convert.ToString(dv.Row["GP_NUM_H"]);
        GP_NUM_J.Text = Convert.ToString(dv.Row["GP_NUM_J"]);
        YP_NUM_X.Text = Convert.ToString(dv.Row["YP_NUM_X"]);
        YP_NUM_D.Text = Convert.ToString(dv.Row["YP_NUM_D"]);
        BP_NUM_H.Text = Convert.ToString(dv.Row["BP_NUM_H"]);
        BP_NUM_J.Text = Convert.ToString(dv.Row["BP_NUM_J"]);


        QTSW_NUM_X.Text = Convert.ToString(dv.Row["QTSW_NUM_X"]);
        QTSW_NUM_J.Text = Convert.ToString(dv.Row["QTSW_NUM_J"]);
        XGZL_NUM_W.Text = Convert.ToString(dv.Row["XGZL_NUM_W"]);
        XGZL_NUM_T.Text = Convert.ToString(dv.Row["XGZL_NUM_T"]);
        XGZL_NUM_J.Text = Convert.ToString(dv.Row["XGZL_NUM_J"]);
        SECU_LEVEL.Text = Convert.ToString(dv.Row["SECU_LEVEL"]);
        SECU_ID.Text = Convert.ToString(dv.Row["SECU_ID"]);
        SECU_ITEMS.Text = Convert.ToString(dv.Row["SECU_ITEMS"]);

        PROTECT_DATE.Text = Convert.ToString(dv.Row["PROTECT_DATE"]);
        //PROTECT_DATE_M.Text = Convert.ToString(dv.Row["PROTECT_DATE_M"]);
        //PROTECT_DATE_D.Text = Convert.ToString(dv.Row["PROTECT_DATE_D"]);
        DEAD_LINE.Text = Convert.ToString(dv.Row["DEAD_LINE"]);
        CG_UNIT.Text = Convert.ToString(dv.Row["CG_UNIT"]);
        CG_CODE.Text = Convert.ToString(dv.Row["CG_CODE"]);
        YS_UNIT.Text = Convert.ToString(dv.Row["YS_UNIT"]);
        YS_CODE.Text = Convert.ToString(dv.Row["YS_CODE"]);

        KEY_WORDS.Text = Convert.ToString(dv.Row["KEY_WORDS"]);
        ABSTRACT.InnerText = Convert.ToString(dv.Row["ABSTRACT"]);
        REMARK.InnerText = Convert.ToString(dv.Row["REMARK"]);




    }


    protected void submit_Click(object sender, EventArgs e)
    {
        ZL_TBL zlobj = new ZL_TBL();
        ZLInfo kc_in = new ZLInfo();

        zlobj.O_TITLE = Request.Form["FileTitle"];
        zlobj.O_GC_DEPART = Request.Form["GC_DEPART"];
        zlobj.O_FILE_ID = Request.Form["FILE_ID"];
        zlobj.O_UNIT = Request.Form["UNIT"];
        zlobj.O_HX_PEOPLE = Request.Form["HX_PEOPLE"];
        zlobj.O_PEOJ_NAME = Request.Form["PEOJ_NAME"];

        zlobj.O_PEOJ_CODE = Request.Form["PEOJ_CODE"];
        zlobj.O_DATA_CLASS = Request.Form["DATA_CLASS"];
        zlobj.O_CLASS_CODE = Request.Form["CLASS_CODE"];
        zlobj.O_ADMIN_REGION = Request.Form["XZArea"];
        zlobj.O_ADMINREG_CODE = Request.Form["ADMINREG_CODE"];
        zlobj.O_MINE_NAME = Request.Form["MINE_NAME"];

        zlobj.O_SHEET_NAME = Request.Form["SHEET_NAME"];
        zlobj.O_SHEET_ID = Request.Form["SHEET_ID"];
        zlobj.O_WORK_LEVEL = Request.Form["WORK_LEVEL"];
        zlobj.O_WORKLEVEL_ID =Request.Form["WORKLEVEL_ID"];
        zlobj.O_START_DATE = Request.Form["START_DATE"];// +"-" + this.START_DATE_M.Text + "-" + this.START_DATE_D.Text;
        zlobj.O_END_DATE = Request.Form["END_DATE"];// + "-" + this.END_DATE_M.Text + "-" + this.END_DATE_D.Text;

        zlobj.O_START_LONGITUDE = int.Parse((Request.Form["START_LONGITUDE_D"] + Request.Form["START_LONGITUDE_F"] + Request.Form["START_LONGITUDE_M"]));
        zlobj.O_START_LATITUDE = int.Parse((Request.Form["START_LATITUDE_D"] + Request.Form["START_LATITUDE_F"] + Request.Form["START_LATITUDE_M"]));
        zlobj.O_END_LONGITUDE = int.Parse((Request.Form["END_LONGITUDE_D"] + Request.Form["END_LONGITUDE_F"] + Request.Form["END_LONGITUDE_M"]));
        zlobj.O_END_LATITUDE = int.Parse((Request.Form["END_LATITUDE_D"] + Request.Form["END_LATITUDE_F"] + Request.Form["END_LATITUDE_M"]));
        zlobj.O_MAJOR_MINE = Request.Form["MineType"];
        zlobj.O_MINE_CODE = Request.Form["MINE_CODE"];

        zlobj.O_PUTIN_DATE = Request.Form["PUTIN_DATE"]; // +"-" + this.PUTIN_DATE_M.Text + "-" + this.PUTIN_DATE_D.Text;
        zlobj.O_TRANSF_CODE = this.TRANSF_CODE.Text;
        zlobj.O_YXIN_NUM_ZL = int.Parse((Request.Form["YXIN_NUM_ZL"]));
        zlobj.O_YXIN_NUM_X = int.Parse((Request.Form["YXIN_NUM_X"]));
        zlobj.O_YXIN_NUM_M = int.Parse((Request.Form["YXIN_NUM_M"]));
        zlobj.O_YXIE_NUM_ZL = int.Parse((Request.Form["YXIE_NUM_ZL"]));

        zlobj.O_YXIE_NUM_X = int.Parse((Request.Form["YXIE_NUM_X"]));
        zlobj.O_YXIE_NUM_ZL = int.Parse((Request.Form["YXIE_NUM_ZL"]));
        zlobj.O_YXIE_NUM_X = int.Parse((Request.Form["YXIE_NUM_X"]));
        zlobj.O_YXIE_NUM_D = int.Parse((Request.Form["YXIE_NUM_D"]));
        zlobj.O_BB_NUM_X = int.Parse((Request.Form["BB_NUM_X"]));
        zlobj.O_BB_NUM_K = int.Parse((Request.Form["BB_NUM_K"]));

        zlobj.O_BB_NUM_K_BIG = int.Parse((Request.Form["BB_NUM_K_BIG"]));
        zlobj.O_GP_NUM_H = int.Parse((Request.Form["GP_NUM_H"]));
        zlobj.O_GP_NUM_J = int.Parse((Request.Form["GP_NUM_J"]));
        zlobj.O_YP_NUM_X = int.Parse((Request.Form["YP_NUM_X"]));
        zlobj.O_YP_NUM_D = int.Parse((Request.Form["YP_NUM_D"]));
        zlobj.O_BP_NUM_H = int.Parse((Request.Form["BP_NUM_H"]));

        zlobj.O_BP_NUM_J = int.Parse((Request.Form["BP_NUM_J"]));
        zlobj.O_QTSW_NUM_X = int.Parse((Request.Form["QTSW_NUM_X"]));
        zlobj.O_QTSW_NUM_J = int.Parse((Request.Form["QTSW_NUM_J"]));
        zlobj.O_XGZL_NUM_W = int.Parse((Request.Form["XGZL_NUM_W"]));
        zlobj.O_XGZL_NUM_T = int.Parse((Request.Form["XGZL_NUM_T"]));
        zlobj.O_XGZL_NUM_J = int.Parse((Request.Form["XGZL_NUM_J"]));

        zlobj.O_SECU_LEVEL = Request.Form["SECU_LEVEL"];
        zlobj.O_SECU_ID = Request.Form["SECU_ID"];
        zlobj.O_SECU_ITEMS = Request.Form["SECU_ITEMS"];
        zlobj.O_PROTECT_DATE =Request.Form["PROTECT_DATE"];// +"-" + this.PROTECT_DATE_M.Text + "-" + this.PROTECT_DATE_D.Text;
        zlobj.O_DEAD_LINE = Request.Form["DEAD_LINE"];
        zlobj.O_CG_UNIT = Request.Form["CG_UNIT"];

        zlobj.O_CG_CODE = Request.Form["CG_CODE"];
        zlobj.O_YS_UNIT = Request.Form["YS_UNIT"];
        zlobj.O_YS_CODE = Request.Form["YS_CODE"];
        zlobj.O_KEY_WORDS =Request.Form["KEY_WORDS"];
        zlobj.O_ABSTRACT = Request.Form["ABSTRACT"];
        zlobj.O_REMARK = Request.Form["REMARK"];

       

        if (kc_in.UpdateZLInfo(zlobj)==1)
        {
            bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/ZLManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/ZLManage.aspx'</script>");
        }
    }
}